import mockApi from "@/api/mockApi";

export default class residentApi {
  static residents = [
    {id: 1, name: '张大小', phone: '13900000111', email: 'zhangsan@qq.com', buildingId: 1, buildingName: '北区1栋', roomId: 1, roomNumber: '301', moveInDate: '2022-01-01', type: 10, createTime: '2024-01-01 12:12:12', modifyTime: '2024-02-02 13:13:13'},
    {id: 2, name: '李四三', phone: '13900000222', email: 'lishishi@qq.com', buildingId: 2, buildingName: '北区2栋', roomId: 1, roomNumber: '402', moveInDate: '2023-02-02', type: 10, createTime: '2024-02-02 12:12:12', modifyTime: '2024-03-03 13:13:13'},
    {id: 3, name: '王无语', phone: '13900000333', email: 'wangwuyu@qq.com', buildingId: 2, buildingName: '北区2栋', roomId: 1, roomNumber: '503', moveInDate: '2024-03-03', type: 10, createTime: '2024-03-03 12:12:12', modifyTime: '2024-04-04 13:13:13'},
    {id: 4, name: '赵元长', phone: '13900000444', email: 'zhaoyuan@qq.com', buildingId: 3, buildingName: '南区1栋', roomId: 1, roomNumber: '604', moveInDate: '2022-04-04', type: 20, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 5, name: '钱一一', phone: '13900000555', email: 'qianyiyi@qq.com', buildingId: 3, buildingName: '南区1栋', roomId: 1, roomNumber: '204', moveInDate: '2023-04-04', type: 10, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 6, name: '王双双', phone: '13900000666', email: 'wushuang@qq.com', buildingId: 4, buildingName: '东区1栋', roomId: 1, roomNumber: '304', moveInDate: '2024-04-04', type: 10, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'},
    {id: 7, name: '郑艳南', phone: '13900000777', email: 'zhengyan@qq.com', buildingId: 4, buildingName: '东区1栋', roomId: 1, roomNumber: '404', moveInDate: '2021-04-04', type: 20, createTime: '2024-04-04 12:12:12', modifyTime: '2024-05-05 13:13:13'}
  ]

  static async save (params) {
    console.log('residentApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('residentApi find params', params)
    const response = await mockApi.queryPageSuccessfully(residentApi.residents)
    return response.data
  }

  static async findById (id) {
    console.log('residentApi findById id', id)
    let target = {}
    for (let a of residentApi.residents) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('residentApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}